package com.ruoyi.cmdb.service.impl.rabbitmq.direct.listense;

import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

import java.util.Objects;

@Component //这个注解,定义一个bean,只有有了这个注解,spring才能加载这个bean
public class MessageListener {
    @RabbitListener(queues = "cmdbtestQueue") //指定消息队列的名称,可以是个数组,即监听多个队列
    public void receive(String id){
        if (Objects.equals(id, "null")){
            System.out.println("lisentener从队列中得到了消息:"+id);
        }else{
            System.out.println("lisentener从队列中得到了消息:"+id);
        }
    }
}
